// OnStyle
//
// Copyright (c)  Daigo Tanaka
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Information expert on elements

onStyle.elements = function(main)
{
var private = {};

var dragElement = null; // Element being dragged
var selectedElement = null; // Selected element to be edited/designed
var elementInFocus = null; // Mouse-overed element: Need to use this to support IE in onMouseDown()

var highestZIndex = 10;
var highestZIndexForElement = 9;

this.getHighestZIndex = function()
{
  return highestZIndex;
}

this.getHighestZIndexForElement = function()
{
  return highestZIndexForElement;
}

this.getSelectedElement = function()
{
  return selectedElement;
}

this.selectElement = function(element)
{
  selectedElement = element;
}

this.getElementInFocus = function()
{
  return elementInFocus;
}

this.setElementInFocus = function(element)
{
  elementInFocus = element;
}

this.getDragElement = function()
{
  return dragElement;
}

this.setDragElement = function(element)
{
  dragElement = element;
}
this.isEditable = function(element)
{
  if (element && element != document && element.id != "" && element.id != onStyle.DialogID  && element.id != onStyle.EditorAreaID  && element.id != onStyle.OutputAreaID){
    return true;
  }
  return false;
};

this.isDraggable = function(element)
{
  if (element && element != document && element != main.getRootContainer() && element.id != ""  && element.id != onStyle.EditorAreaID  && element.id != onStyle.OutputAreaID && element.id != onStyle.EditorTitleID && element.id != onStyle.EditorID){
    return true;
  }
  return false;
};

this.initializeElement = function(element)
{
  element.style.position = "absolute";
  element.style.top = element.offsetTop.toString() + "px";
  element.style.left = element.offsetLeft.toString() + "px";
  element.style.width = element.offsetWidth.toString() + "px";
  element.style.height = element.offsetHeight.toString() + "px";
};

};

